home *** CD-ROM | disk | FTP | other *** search
/ Suzy B Software 2 / Suzy B Software CD-ROM 2 (1994).iso / extras / programm / gemfsc20 / gemfsc20.lzh / GEMFBIND / AESFSEL2.S < prev    next >
Text File  |  1993-03-26  |  12KB  |  333 lines

  1.  
  2. ;*========================================================================
  3. ;*
  4. ;* AESFAST Public Domain GEM bindings.
  5. ;*    Maintenance:
  6. ;*     02/11/89 v1.1: This source file is new with this version.
  7. ;*
  8. ;*     04/07/89 v1.2:
  9. ;*              The calculation of the location of the prompt on the
  10. ;*              screen has been changed.    It was placed one boxchar height
  11. ;*              down on the screen, putting it right below the menu bar.
  12. ;*              This didn't look too good on a big-monitor system, so now
  13. ;*              it is calculated by centering the box, then subtracting a
  14. ;*              fixed offset from the centered Y to make it appear right
  15. ;*              above the fsel'er box.  The offset is 9 character heights,
  16. ;*              (plus 2 extra char heights for the prompt itself), less
  17. ;*              2 pixels (just to line everything up real neat).
  18. ;*
  19. ;*     07/22/89 v1.3:
  20. ;*              Bugfix...A 'bra.s' instruction was missing just before the
  21. ;*              'strcpy' routine, causing 4 bombs on a pre-1.4 machine.
  22. ;*========================================================================
  23.  
  24. ;*************************************************************************
  25. ;*
  26. ;* Extended fsel manager routine.
  27. ;*    (Including simulation routines for pre-TOS 1.4 systems).
  28. ;*
  29. ;*************************************************************************
  30.  
  31. ;-------------------------------------------------------------------------
  32. ; fsel_exinput
  33. ;  This function is new with TOS 1.4, but this binding supports it in all
  34. ;  TOS/AES versions with a simulation of the new routine's actions if the
  35. ;  AES version we're running under is pre-TOS 1.4
  36. ;-------------------------------------------------------------------------
  37.  
  38.           globl     _fsel_exinput
  39. _fsel_exinput:
  40.  
  41. ;          .cargs    #8,pinpath.l,pinsel.l,pbutton.l,plabel.l
  42.  
  43. pinpath         =    8
  44. pinsel            =    12
  45. pbutton         =    16
  46. plabel            =    20
  47.  
  48.           link        a6,#-4
  49.  
  50.           move.w    _gl_apversion,d0         ; Check the AES version.  If
  51.           cmp.w     #$0104,d0                 ; it's $0104, we're running
  52.           beq.b     ramaes                     ; on the RAM-based TOS 1.4
  53.           cmp.w     #$0130,d0                 ; Else, if it's less than $0130
  54.           blt        simu_exinput             ; we have to simulate exinput.
  55. ramaes:
  56.           move.l    plabel(a6),d0             ; Swap the button and prompt
  57.           move.l    pbutton(a6),plabel(a6)     ; string pointers to make the
  58.           move.l    d0,pbutton(a6)             ; addrin stuff contiguous.
  59.  
  60.           move.l    #$5B000203,d0             ; AControl  91,0,2,3                  ; AES v1.3 & up: fsel_exinput
  61.           moveq.l    #-4,d1                     ; is a legal function, do it.
  62.           lea        pinpath(a6),a0             ; a0 -> addrin
  63.           jsr        aes_call                 ; Call AES.
  64.  
  65.           move.l    plabel(a6),d0             ; Swap the prompt string and
  66.           move.l    pbutton(a6),plabel(a6)     ; button pointers back to how
  67.           move.l    d0,pbutton(a6)             ; they were on entry.
  68.  
  69.           moveq.l    #-4,d1                     ; Return values from
  70.           lea        pbutton(a6),a1             ; intout[] array to caller
  71.           jmp        (a0)                     ; via aes_return routine.
  72.  
  73. ;*************************************************************************
  74. ; The following code and data supports the exinput simulation routines.
  75. ;
  76. ; The simulator supports *most* of the TOS 1.4 features, to wit:
  77. ;
  78. ;  - A prompt string of up to 30 chars is displayed with the file selector.
  79. ;  - The file selector handles <CR> like TOS 1.4 does (see comments below).
  80. ;  - If the caller passes in a path with a leading '\' it will be appended
  81. ;     to the current default drive & path (and the whole resulting string
  82. ;     will be returned upon exit).
  83. ;  - The current DTA is preserved.
  84. ;  - The current drive and path is preserved.
  85. ;
  86. ; These are differences between the simulator and TOS 1.4:
  87. ;
  88. ;  - There are no drive buttons in the dialog.
  89. ;  - There is still a static limit of 100 files that can be displayed.
  90. ;  - Long pathnames are NOT handled correctly.
  91. ;  - Multiple abort/continue situations will still give problems.
  92. ;  - The redraw sequence of the dialog is still the same.
  93. ;
  94. ; The things not supported are, of course, things I can't affect without
  95. ; completely re-writing the fsel_input handler.
  96. ;*************************************************************************
  97.  
  98. ;-------------------------------------------------------------------------
  99. ; Define variables which will be accessed as offsets from a3.
  100. ;  (Storage for these things will be allocated from the stack at runtime).
  101. ;-------------------------------------------------------------------------
  102.  
  103. savddrv   =         0
  104. savdpath  =         2+savddrv
  105. savipath  =         128+savdpath
  106. savdta      =         128+savipath
  107. tmpdta      =         4+savdta
  108. SAV_SZ      =         44+tmpdta
  109.  
  110. ;-------------------------------------------------------------------------
  111. ; Define variables.
  112. ;-------------------------------------------------------------------------
  113.  
  114.           bss
  115.  
  116. lastkeyCR: ds.w     1          ; Flag: was last keystroke during fsel a <CR>?
  117. oldbios:   ds.l     1          ; Old BIOS vector address.
  118.  
  119.           text
  120.  
  121. ;-------------------------------------------------------------------------
  122. ; This routine is installed as a hook in the BIOS vector for the duration
  123. ; of the the fsel_input call.  It watches for a Bconin(2) call (which will
  124. ; be the AES asking for a character).  The Bconin call is done from in
  125. ; here such that we get the character back from the real BIOS and examine
  126. ; it.  If the character is a <CR>, we set the flag to say so and return
  127. ; the character to the caller.    If not a <CR> we clear the flag and
  128. ; return the character.
  129. ;
  130. ; The whole reason for this is a bug in the pre-TOS 1.4 AES: If the user
  131. ; edited the path but didn't click the mouse on anything or change the
  132. ; filename field, then hit <CR>, the system returned a CANCEL status. This
  133. ; BIOS hook is the only way to tell for sure that the exit was via <CR>.
  134. ;-------------------------------------------------------------------------
  135.  
  136. bioshook:
  137.           lea        6(sp),a0            ; Assume super mode caller.
  138.           btst.b    #5,(sp)             ; Were we in super mode?
  139.           bne.b     supermode            ; No, user mode...
  140.           move.l    usp,a0                ; So look at parms on user stack.
  141. supermode:
  142.           move.l    #$00020002,d0        ; Bconin(2) function...
  143.           cmp.l     (a0),d0             ; Is it that?
  144.           bne.b     biospunt            ; Nope, punt.
  145.  
  146.           move.l    d0,-(sp)            ; Stack Bconin(2) function code,
  147.           bsr.b     bioscall            ; Go get the character.
  148.           addq.l    #4,sp
  149.  
  150.           cmp.b     #$0D,d0            ; Is the char a <CR>? If so set the
  151.           seq        lastkeyCR            ; flag, either way, return the char.
  152. biosreturn:
  153.           rte                            ; Return the char to the caller.
  154.  
  155. bioscall:                                ; Call original BIOS, with return
  156.           move.w    sr,-(sp)            ; to caller of 'bioscall'.
  157. biospunt:
  158.           move.l    oldbios,-(sp)        ; Not a BIOS function we handle,
  159.           rts                            ; punt control to the real BIOS.
  160.  
  161. ;-----------------------------------------------------------------------------
  162. ; a couple mundane things...
  163. ;-----------------------------------------------------------------------------
  164.  
  165. strcpy:
  166.           move.b    (a0)+,(a1)+
  167.           bne.b     strcpy
  168.           rts
  169.  
  170. strcmp:
  171.           move.b    (a0)+,d0
  172.           beq.b     checkdone
  173.           cmp.b     (a1)+,d0
  174.           beq.b     strcmp
  175.           rts
  176. checkdone:
  177.           tst.b     (a1)
  178.           rts
  179.  
  180. ;-------------------------------------------------------------------------
  181. ; simu_exinput - Simulate an exinput call on pre-TOS 1.4 systems.
  182. ;-------------------------------------------------------------------------
  183.  
  184. simu_exinput:
  185.  
  186.           movem.l    d2/a2-a3,-(sp)           ; Save registers.
  187.  
  188. ;-------------------------------------------------------------------------
  189. ; Once the one-time stuff is done (and on all subsequent calls...) do
  190. ; the actual simulation of the TOS 1.4 exinput:
  191. ;
  192. ;  - The current default drive and path is saved.
  193. ;  - The current DTA address is saved, and a temporary DTA is installed.
  194. ;  - If the pathname passed to exinput starts with a '\', the passed-in
  195. ;     path is appended to the current default path.
  196. ;  - A hook is placed into the BIOS vector to watch for <CR> being hit,
  197. ;     so that we can mimick the new fsel's actions when just the pathname
  198. ;     is edited, and the user hits <CR> (to move to the filename field).
  199. ;  - Call fsel_input() (the simulator routine that puts up a prompt box)
  200. ;  - Check to see if our BIOS hook set the flag saying a <CR> was the last
  201. ;     key hit.  If so, see if the pathname in the fsel dialog was changed.
  202. ;     If so, the user probably hit <CR> after typing the path (I always do),
  203. ;     so we loop back to do the fsel dialog again.  If the user clicked on
  204. ;     OK instead of hitting return, this won't happen.  Also, if the user
  205. ;     doesn't change the path (but perhaps does change the filename), then
  206. ;     hits return, we will not repeat the dialog.
  207. ;  - Restore the current drive & path, and the old DTA.
  208. ;  - De-install the BIOS hook.
  209. ;  - Return to caller.
  210. ;-------------------------------------------------------------------------
  211.  
  212. do_simulation:
  213.  
  214. ;          .cargs    #8,pinpath.l,pinsel.l,pbutton.l,plabel.l
  215.  
  216. pinpath          =     8
  217. pinsel             =     12
  218. pbutton          =     16
  219. plabel             =     20
  220.  
  221.           sub.w     #SAV_SZ,sp            ; Allocate save area from stack,
  222.           move.l    sp,a3                ; load save area base register.
  223.  
  224.           move.w    #$19,-(sp)            ; get/save current drive.
  225.           trap        #1
  226.           addq.l    #2,sp
  227.           move.w    d0,savddrv(a3)
  228.           add.b     #$41,d0
  229.           move.b    d0,savdpath(a3)
  230.           move.b    #$3A,1+savdpath(a3)
  231.  
  232.           clr.w     -(sp)                ; get/save current path.
  233.           pea        2+savdpath(a3)
  234.           move.w    #$47,-(sp)
  235.           trap        #1
  236.           addq.l    #8,sp
  237.  
  238.           tst.b     2+savdpath(a3)
  239.           bne.b     gotpath
  240.           move.w    #$5C00,2+savdpath(a3)          ; 5C00 == "\<NULL>"
  241.  
  242. gotpath:
  243.  
  244.           move.w    #$2F,-(sp)                      ; get the process's
  245.           trap        #1                              ; current dta; save it.
  246.           move.l    d0,savdta(a3)
  247.           addq.l    #2,sp
  248.  
  249.           pea        tmpdta(a3)                      ; switch to a private dta.
  250.           move.w    #$1A,-(sp)
  251.           trap        #1
  252.           addq.l    #6,sp
  253.  
  254.           move.l    pinpath(a6),a0        ; a0 -> input path
  255.           lea        savipath(a3),a1     ; a0 -> path save area
  256.           cmp.b     #$5C,(a0)           ; Leading '\' in input path?
  257.           bne.b     copypath            ; Nope, go do straight copy.
  258.           lea        savdpath(a3),a0     ; Yep, so copy the current
  259.           bsr        strcpy                ; default path to the save
  260.           cmp.b     #$5C,-2(a1)
  261.           bne.b     noterm
  262.           subq.l    #1,a1
  263. noterm:
  264.           move.l    pinpath(a6),a0        ; area first, then concat
  265.           subq.l    #1,a1                ; the input path onto the
  266.           bsr        strcpy                ; end of it.  Since we changed
  267.           lea        savipath(a3),a0     ; it in the save area, we need to
  268.           move.l    pinpath(a6),a1        ; copy it back to the input area.
  269. copypath:
  270.           bsr        strcpy
  271.  
  272.           pea        bioshook(pc)        ; install bios hook
  273.           move.w    #$2D,-(sp)
  274.           move.w    #5,-(sp)
  275.           trap        #13
  276.           addq.l    #8,sp
  277.           move.l    d0,oldbios
  278.  
  279. fsel_loop:
  280.  
  281.           clr.w     lastkeyCR            ; Clear <CR> flag.
  282.  
  283.           jsr        FselSimu          ; go do prompted fsel
  284.  
  285.           tst.w     lastkeyCR            ; Hack to fix an AES bug: If our
  286.           beq.b     fsel_done            ; BIOS hook says the last key was
  287.           move.w    #1,-2(a6)            ; a CR, force the button to OK.
  288.  
  289.           move.l    pinpath(a6),a0        ; see if the user changed the path;
  290.           lea        savipath(a3),a1     ; if not, we're done.
  291.           bsr        strcmp
  292.           beq.b     fsel_done
  293.  
  294.           move.l    pinpath(a6),a0        ; user changed path, save the new
  295.           lea        savipath(a3),a1     ; path (so we can detect another
  296.           bsr        strcpy                ; change) and loop to do the fsel
  297.           bra.b     fsel_loop            ; again.
  298.  
  299. fsel_done:
  300.  
  301.           move.w    savddrv(a3),-(sp)    ; restore default drive
  302.           move.w    #$0E,-(sp)
  303.           trap        #1
  304.           addq.l    #4,sp
  305.  
  306.           pea        savdpath(a3)        ; restore default path
  307.           move.w    #$3B,-(sp)
  308.           trap        #1
  309.           addq.l    #6,sp
  310.  
  311.           move.l    savdta(a3),-(sp)    ; restore process's dta
  312.           move.w    #$1A,-(sp)
  313.           trap        #1
  314.           addq.l    #6,sp
  315.  
  316.           move.l    oldbios,-(sp)        ; remove bios hook
  317.           move.w    #$2D,-(sp)
  318.           move.w    #5,-(sp)
  319.           trap        #13
  320.           addq.l    #8,sp
  321.  
  322.           add.w     #SAV_SZ,sp            ; Deallocate save area from stack.
  323.           movem.l    (sp)+,d2/a2-a3        ; Restore working regs.
  324.  
  325.           move.l    pbutton(a6),a1        ; Return the values from
  326.           move.w    -2(a6),(a1)         ; intout to the caller.
  327.           move.w    -4(a6),d0
  328.           unlk        a6
  329.           rts
  330.  
  331. ;          end of code
  332.  
  333.